﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Web.UI;

public partial class UserControls_OrderShow : UCBase 
{
    public UserControls_OrderShow()
    {
        Name = "生成订单";

        swpas = new ShoveWebPartAttribute[9];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "", 759, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("导航高度", "1,300", 23, "导航高度");
        swpas[2] = new ShoveWebPartAttribute_Int("导航单元格宽度", "1,1000", 107, "导航单元格宽度");
        swpas[3] = new ShoveWebPartAttribute_Image("导航单元格图片1", "", "images/title_bg_1.jpg", "导航单元格图片1");
        swpas[4] = new ShoveWebPartAttribute_Image("导航单元格图片2", "", "images/title_bg_hui.jpg", "导航单元格图片2");
        swpas[5] = new ShoveWebPartAttribute_Text("导航文本样式", "", "black12", "导航文本样式");
        swpas[6] = new ShoveWebPartAttribute_Color("控件边框颜色", "#cccccc", "控件边框颜色");

        swpas[7] = new ShoveWebPartAttribute_Text("提示标题样式", "", "black12", "提示标题样式");
        swpas[8] = new ShoveWebPartAttribute_Int("标题行高", "1,500", 26, "标题行高");
    }

    private void InitLayOut()
    {
        tabctr.Width = swpAttributes[0];
        tabctr.BgColor = swpAttributes[6];

        //tdsign.Height = swpAttributes[1];
        //tdsign.Width = swpAttributes[2];
        //tdsign.Attributes.Add("class", swpAttributes[5]);
        //tdsign.Style.Add(HtmlTextWriterStyle.BackgroundImage,"url('"+swpAttributes[3]+"')");

        //tdspace.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url('" + swpAttributes[4] + "')");
        //tdspace.Width = (Shove._Convert.StrToInt(swpAttributes[0], 759) - Shove._Convert.StrToInt(swpAttributes[2], 139)).ToString();

        tdOrder.Height = swpAttributes[8];
        tdOrder.Attributes.Add("class", swpAttributes[7]);
        tdOrderDatetime.Height = swpAttributes[8];
        tdOrderDatetime.Attributes.Add("class", swpAttributes[7]);

        tdConsigneeName.Height = swpAttributes[8];
        tdConsigneeName.Attributes.Add("class", swpAttributes[7]);
        tdEmail.Height = swpAttributes[8];
        tdEmail.Attributes.Add("class", swpAttributes[7]);

        tdtel.Height = swpAttributes[8];
        tdtel.Attributes.Add("class", swpAttributes[7]);
        tdmobil.Height = swpAttributes[8];
        tdmobil.Attributes.Add("class", swpAttributes[7]);

        tdcode.Height = swpAttributes[8];
        tdcode.Attributes.Add("class", swpAttributes[7]);
        tdAddress.Height = swpAttributes[8];
        tdAddress.Attributes.Add("class", swpAttributes[7]);

        tdMoney.Height = swpAttributes[8];
        tdMoney.Attributes.Add("class", swpAttributes[7]);

        tdPayType.Height = swpAttributes[8];
        tdPayType.Attributes.Add("class", swpAttributes[7]);
        tdType.Height = swpAttributes[8];
        tdType.Attributes.Add("class", swpAttributes[7]);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (_Customer == null)
            {
                Response.Redirect("Default.aspx?PN=Login&Type=Cart");
            }
            else
            {
                long ID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("SaleID"), 0);

                LoadData(ID);
            }
        }

        InitLayOut();
    }
    
    /// <summary>
    /// 显示生成订单
    /// </summary>
    /// <param name="id"></param>
    private void LoadData(long ID)
    {       
        DataTable dt = new DAL.Views.V_Shop_SalesMaster().Open("", "ID=" + ID, "");
        if (dt == null || dt.Rows.Count == 0)
        {
            return;
        }
        DataRow dr = dt.Rows[0];

        lbSalesNO.Text = dr["SalesNo"].ToString();
        lbCreateDate.Text = dr["CreateDate"].ToString();
        lbConsigneeName.Text = dr["ConsigneeName"].ToString();
        lbConsigneeEmail.Text = dr["ConsigneeEmail"].ToString();
        lbConsigneeTel.Text = dr["ConsigneeTel"].ToString();
        lbConsigneeMobile.Text = dr["ConsigneeMobile"].ToString();

        lbConsigneeZipCode.Text = dr["ConsigneeZipCode"].ToString();
        lbConsigneeAdress.Text = dr["ConsigneeAdress"].ToString();
        lbActualMoney.Text = dr["ActualMoney"].ToString();
        lbPayType.Text = (dr["PayType"].ToString() == "1") ? "在线支付" : "货到付款";
        lbCarriageType.Text = (dr["CarriageType"].ToString() == "1") ? "快递(收取一定费用)" : "平邮(免费)";
    }

    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
